'use strict';

import 'framework7';
import 'framework7.ios.css';
import 'framework7.ios.color.css';
import '../assets/app.less';

import mainModule from './main/main';
import Router from './router';
import Workplus from './utils/workplus';


var app = {
    init(){
        // alert("index------------> init");
        if(false){
            this.initApp();
        }else{
            // alert("index------------>deviceready");
            this.deviceReady();
        }
    },
    // 如果需要调用cordova 需要在deviceReady后 调用 mainModule.init()
    deviceReady(){
        var self = this;
        document.addEventListener('deviceready', function() {
            // alert("index------------>deviceready callback");
            self.initApp();
            // 绑定返回事件
            // document.addEventListener("backbutton", function(){
            //     app.cordovaBackEvent();
            // }, false);
        }, false);
    },
    cordovaBackEvent(){
        // 物理返回事件
        // Workplus.getOut();
    },
    initApp(){
        // Init App
        window.$ = Dom7;
        window.myApp = new Framework7({
            animateNavBackIcon: true,
            pushState: true,
        });
        myApp.addView('.view-main', {
            domCache: true
        });
        
        mainModule.init();
        Router.init();   
    }
};
app.init();
